package org.demo.config.controller;

import org.demo.config.ConfigBean;
import org.demo.config.ConfigPropertySource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ConfigController {

	@Value("${my.name}")
	private String name;

	@Value("${my.age}")
	private int age ;

	@Autowired
	private ConfigBean configBean; 

	@Autowired
	private ConfigPropertySource configPropertySource;

	@RequestMapping(value="/hello")
	public String hello(){
		return "Hello, "+ name + ": " + age; 
	}

	@RequestMapping(value="/config")
	public String config(){
		return configBean.getGreeting() + " >>> " + configBean.getName() + " >>> "+ configBean.getUuid() + " >>> " + configBean.getMax();
	}


	@RequestMapping(value="/propertySource")
	public String propertySource(){
		return configPropertySource.getName()+"  : "+ configPropertySource.getAge();
	}
}
